import {
    GetEvaluateListWithPage,
    Reply,
    AuditEvaluateToNoPass,
    AuditEvaluateToPass,
} from '@/services/order/orderRates';
import {catchException} from '@/utils/utils';
export default {
    namespace: 'orderRates',

    state: {
        evaluateList: {},
    },

    effects: {

        // 获取订单列表
        *GetEvaluateListWithPage({ params, callBack }, { call, put }) {
            const data = yield call(GetEvaluateListWithPage, params);
            yield catchException(function* (){
                if (data.Code === 0) {
                    yield put({
                        type: 'EvaluateListWithPage',
                        data: data.Data,
                    });
                    callBack && callBack.success(data.Data);
                } else {
                    callBack && callBack.error(data)
                }
            })            
        },
        *Reply({ params, callBack }, { call, put }) {
            const data = yield call(Reply, params);
            yield catchException(function* (){
                if (data.Code === 0) {
                    callBack && callBack.success(data);
                } else {
                    callBack && callBack.error(data)
                }
            })            
        },
        *AuditEvaluateToNoPass({ params, callBack }, { call, put }) {
            const data = yield call(AuditEvaluateToNoPass, params);
            yield catchException(function* (){
                if (data.Code === 0) {
                    callBack && callBack.success(data);
                } else {
                    callBack && callBack.error(data)
                }
            })           
        },
        *AuditEvaluateToPass({ params, callBack }, { call, put }) {
            const data = yield call(AuditEvaluateToPass, params);
            yield catchException(function* (){
                if (data.Code === 0) {
                    callBack && callBack.success(data);
                } else {
                    callBack && callBack.error(data)
                }
            })            
        },
    },

    reducers: {
        EvaluateListWithPage(state, { data }) {
            return {
                ...state,
                evaluateList: data,
            };
        },


    }
}
